<?php

class TimeUtilities
{
	public static function formatSecondsInterval( $inSeconds )
	{
		$seconds = $inSeconds;
		$hours = floor( $seconds / 3600 );
		$seconds = $seconds - ( $hours * 3600 );
		$minutes = floor( $seconds / 60 );
		$seconds = $seconds - ( $minutes * 60 );
		
		$minutes = str_pad( $minutes, 2, "0", STR_PAD_LEFT );
		$seconds = str_pad( $seconds, 2, "0", STR_PAD_LEFT );
		
		$timeStr = $hours . ":" . $minutes . ":" . $seconds;
		return $timeStr;
	}
	
	public static function formatSecondsTimestamp( $timeUNIX )
	{
		$timeStr = date( 'Y-m-d H:i:s', $timeUNIX );
		return $timeStr;
	}
	
	public static function getFormattedTime()
	{
		$timeUNIX = time();
		$timeStr = date( 'Y-m-d H:i:s', $timeUNIX );
		return $timeStr;
	}
	
	
	public static function sqlTimeToSeconds( $sqlTime )
	{
		$dtTime = new DateTime( $sqlTime );
		$unixTime = $dtTime->getTimestamp();
		return $unixTime;
	}
	
	
	public static function addSecondsToSqlTime( $sqlTime, $seconds )
	{
		$dtTime = new DateTime( $sqlTime );
		$unixTime = $dtTime->getTimestamp();
		$unixTime = $unixTime + $seconds;
		$timeStr = date( 'Y-m-d H:i:s', $unixTime );
		return $timeStr;
	}
	
}
